package com.vieewer.btdemo.base

import android.content.Context
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.util.Log
import android.view.KeyEvent
import android.view.WindowManager
import com.lindroid.androidutilskt.statics.AppManager
import com.vieewer.btdemo.utils.ScreenSleepUtil
import com.vieewer.btdemo.view.mycamera.SurfaceCameraActivity
import com.vieewer.btdemo.view.mycamera.SurfaceCameraActivity.SCENE_MODE

abstract class BaseActivity() : AppCompatActivity() {

    protected lateinit var mContext: Context

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        mContext = this
        //设置全屏
        window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN)
        /*导游和菜单页面设置15s息屏，其他功能页面设置不息屏*/
        ScreenSleepUtil.setScreenSleepTime(3600*1000, mContext)

        AppManager.addActivity(this)

    }


    override fun onDestroy() {
        super.onDestroy()
        AppManager.removeActivity(this)
    }



    override fun onKeyUp(keyCode: Int, event: KeyEvent?): Boolean {
        when (keyCode) {

            119 -> { //Fn按键对应键值为119

               /* if (AppManager.currentActivity()!!.localClassName != "view.mycamera.SurfaceCameraActivity") {
                    SurfaceCameraActivity.startActivity(mContext, SCENE_MODE)
                    Log.i("yjj", "base onKeyUp open camera capture")
                }*/

            }

            141 -> { //触控长按按下

            }

            142 -> { //触控长按松开

            }

        }
        return super.onKeyUp(keyCode, event)
    }





}